﻿using WorldView;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using DrawableObjects;
using Sirian.DrawableObject.Actors;

namespace SpecialEffects
{
    /// <summary>
    /// This abstract class represents a special effect.
    /// </summary>
    public abstract class SpecialEffect : DrawableObject
    {
        /// <summary>
        /// The boundings of the visible world.
        /// </summary>
        public Bounding worldBounding;

        public virtual Vector3 startPos
        {
            get;
            protected set;
        }

        public virtual GraphicsDevice device
        {
            get;
            protected set;
        }

        public virtual float birthTime
        {
            get;
            protected set;
        }

        public virtual float maxTime
        {
            get;
            protected set;
        }

        public virtual World world
        {
            get;
            protected set;
        }

        public bool hasFinished
        {
            get;
            protected set;
        }

        /// <summary>
        /// Gets the 2D game position of a special effect. 
        /// </summary>
        /// <returns>The 2D position of a special effect.</returns>
        public override Vector2 getGamePosition()
        {
            Vector2 gamePosition = new Vector2(startPos.X, startPos.Z);
            return gamePosition;
        }

        /// <summary>
        /// Checks whether a special effect has finished and can be removed from the world.
        /// </summary>
        /// <returns>true, if the special effect has finished, false otherwise</returns>
        public abstract bool HasFinished();

        /// <summary>
        /// Draws the special effect.
        /// </summary>
        public abstract void Draw(Effect shader);

        /// <summary>
        /// Checks whether a special effect is in the boundings of the gaming window.
        /// </summary>
        /// <returns>true, if a special effect is in the boundings of the gaming window, false otherwise</returns>
        public bool isInBoundings()
        {
            return worldBounding.isWithinBounding(this.getGamePosition(), 0f);
        }
    }
}

